//
//  DatePicker.m
//  Gradekeeper0.2
//
//  Created by Lily Wang on 11/18/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "DatePicker.h"

@implementation DatePicker
UILabel *label;
UIDatePicker *datePicker;

- (void)viewDidLoad {
    [super viewDidLoad];
	
	//Create label
	label = [[UILabel alloc] init];
	label.frame = CGRectMake(10, 10, 300, 40);
	label.textAlignment = UITextAlignmentCenter;
	
	//Use NSDateFormatter to write out the date in a friendly format
	NSDateFormatter *df = [[NSDateFormatter alloc] init];
	df.dateStyle = NSDateFormatterMediumStyle;
	label.text = [NSString stringWithFormat:@"%@",
				  [df stringFromDate:[NSDate date]]];
	[df release];
	[self.view addSubview:label];
	[label release];
	
	// Initialization code
	datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 250, 325, 250)];
	datePicker.datePickerMode = UIDatePickerModeDate;
	datePicker.hidden = NO;
	datePicker.date = [NSDate date];
	[datePicker addTarget:self
	               action:@selector(changeDateInLabel:)
	     forControlEvents:UIControlEventValueChanged];
	[self.view addSubview:datePicker];
	[datePicker release];
}

- (void)dealloc {
	[datePicker release];
	[label release];
	[super dealloc];
}

@end